package com.simtop.hj.utils;

import java.io.*;

public class PythonUtil {
    public static String getPort(String account,String password){
        //F:\workspace\hj\python\er.py
        //C:\manage\python
        //C:\manage\python\er.py
        StringBuilder sb=new StringBuilder();
        String[] args = new String[] { "python", "C:\\manage\\python\\er.py",account ,password,"1" };
        try{
            Process proc = Runtime.getRuntime().exec(args); //执行py文件
            InputStreamReader stdin = new InputStreamReader(proc.getInputStream());
            LineNumberReader input = new LineNumberReader(stdin);
            String line="";
            while ((line = input.readLine())!=null) {
                sb.append(line);
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return sb.toString();
    }

    public static String delPort(String account,String password){
        //F:\workspace\hj\python\er.py
        //C:\manage\python
        StringBuilder sb=new StringBuilder();
        String[] args = new String[] { "python", "C:\\manage\\python\\er.py",account ,password,"0" };
        try{
            Process proc = Runtime.getRuntime().exec(args); //执行py文件
            InputStreamReader stdin = new InputStreamReader(proc.getInputStream());
            LineNumberReader input = new LineNumberReader(stdin);
            String line="";
            while ((line = input.readLine())!=null) {
                sb.append(line);
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return sb.toString();
    }

    public static void main(String[] args) {
        String str="";
        System.out.println(str.replaceAll("\"\"",""));
    }
}
